package il.ac.braude.sona.IcmUnitTest;

import il.ac.braude.sona.constants.TestingParamKit;
import il.ac.braude.sona.control.ReportsController;

import java.util.ArrayList;

import junit.framework.TestCase;

public class FrozenMedianTest extends TestCase {
	private ReportsController reportController = new ReportsController();
	private TestingParamKit myKit;
	private StatisticsFromData myStatics;

	protected void setUp() throws Exception {
		myKit = TestingParamKit.getTestingKit();
	}

	public void testMedianPerWeek() {
		ArrayList<Object> values = new ArrayList<Object>();
		values.add("Periodic Report");
		values.add("2013-06-16");
		values.add("2013-06-23");
		values.add("Previous Periodic Reports");
		reportController.selectReport();
		reportController.execReportInfo((String) values.get(0), values);
		myKit.waitForNotify();
		myStatics=new StatisticsFromData(reportController.frame.suspendedResults);
		assertTrue(myStatics.checkMedian(reportController.frame.stac_suspend.median()));
		assertFalse(myStatics.checkMedian(reportController.frame.stac_suspend.getMean()));
	}
	
	public void testMedianPerMonth() {
		ArrayList<Object> values = new ArrayList<Object>();
		values.add("Periodic Report");
		values.add("2013-05-24");
		values.add("2013-06-23");
		values.add("Previous Periodic Reports");
		reportController.selectReport();
		reportController.execReportInfo((String) values.get(0), values);
		myKit.waitForNotify();
		myStatics=new StatisticsFromData(reportController.frame.suspendedResults);
		assertTrue(myStatics.checkMedian(reportController.frame.stac_suspend.median()));
		assertFalse(myStatics.checkMedian(reportController.frame.stac_suspend.getMean()));
	}

	public void testMedianPerQuarter() {
		ArrayList<Object> values = new ArrayList<Object>();
		values.add("Periodic Report");
		values.add("2013-03-28");
		values.add("2013-06-27");
		values.add("Previous Periodic Reports");
		reportController.selectReport();
		reportController.execReportInfo((String) values.get(0), values);
		myKit.waitForNotify();
		myStatics=new StatisticsFromData(reportController.frame.suspendedResults);
		assertTrue(myStatics.checkMedian(reportController.frame.stac_suspend.median()));
		assertFalse(myStatics.checkMedian(reportController.frame.stac_suspend.getMean()));
	}
	
	public void testMedianPer6Months() {
		ArrayList<Object> values = new ArrayList<Object>();
		values.add("Periodic Report");
		values.add("2013-01-07");
		values.add("2013-06-07");
		values.add("Previous Periodic Reports");
		reportController.selectReport();
		reportController.execReportInfo((String) values.get(0), values);
		myKit.waitForNotify();
		myStatics=new StatisticsFromData(reportController.frame.suspendedResults);
		assertTrue(myStatics.checkMedian(reportController.frame.stac_suspend.median()));
		assertFalse(myStatics.checkMedian(reportController.frame.stac_suspend.getMean()));
	}


}
